package com.eeepay.eeepay_v2.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.eeepay.eeepay_v2.R;
import com.eeepay.eeepay_v2.model.AppInfo;
import com.eeepay.v2_library.util.ImageLoaderUtils;

/**
 * Created by zw on 2016/10/10 0010.
 * 二维码
 */
public class QRCodeDialog extends Dialog {

    private Context mContext;
    private ImageView iv;
    private TextView tv;

    public QRCodeDialog(Context context) {
        super(context);
        this.mContext = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
    }

    private void init() {
        setContentView(R.layout.qr_code_dialog);
        iv = (ImageView) findViewById(R.id.iv_qr_code);
        tv = (TextView) findViewById(R.id.tv_qr_name);
    }

    @Override
    public void show() {
        super.show();
//        tv.setText(AppInfo.getInstance().getAppName());
//        ImageLoaderUtils.loadBitmap(AppInfo.
//   etInstance().getCodeUrl(), iv);
    }

    @Override
    public void dismiss() {
        super.dismiss();
        iv.setImageDrawable(null);
    }

    public void setName(String name) {
        if (!TextUtils.isEmpty(name))
            tv.setText(name);
    }

    public void setCodeUrl(String url) {
        if (!TextUtils.isEmpty(url))
            ImageLoaderUtils.loadBitmap(url, iv);
    }
}
